import { useSyncExternalStore } from "react";
import { userStore } from "./usersStore";
 

 export  default function SyncExternalStore(){
  const users=useSyncExternalStore(userStore.subscribe,userStore.getSnapshot)
  console.log(users,'users');
  return (
    <>
    <button onClick={()=>userStore.addUser('惠妹真漂亮~')}>ADD user</button>
    <ul>
      {
        users.map((item,index)=><li key={index}>{item}</li>)
      }
    </ul>
    </>
  )
 }